package com.css.fxfzcpxx.modules.customizedServices.service.impl;

import com.css.fxfzcpxx.constants.YNEnum;
import com.css.fxfzcpxx.modules.customizedServices.CurSevicesVo;
import com.css.fxfzcpxx.modules.customizedServices.entity.CusServices;
import com.css.fxfzcpxx.modules.customizedServices.repository.CusServicesRepository;
import com.css.fxfzcpxx.modules.customizedServices.service.CusServicesService;
import com.css.fxfzcpxx.util.UUIDGenerator;
import com.css.fxfzcpxx.web.PlatformSessionContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

/**
 * @Author:
 * @CreateTime: 2023/4/14 9:52
 * @Description:
 */
@Service
public class CusServicesServiceImpl implements CusServicesService {
    @Resource
    CusServicesRepository cusServicesRepository;

    @Override
    public void save(CusServices cusServices) {
        cusServices.setId(UUIDGenerator.getUUID());
        cusServices.setCreateUser(PlatformSessionContext.getUserID());
        cusServices.setCreateTime(new Date());
        cusServices.setMessageStatus("0");
        cusServicesRepository.save(cusServices);
    }

    @Override
    public Map<String, Object> getPage(String keyword, int curPage, int pageSize) {
        Map<String, Object> page = cusServicesRepository.getPage(keyword,curPage, pageSize);
        return page;
    }

    @Override
    public CusServices findById(String id) {
        return cusServicesRepository.findById( id);
    }

    @Override
    public void updateMessageStatus(CurSevicesVo curSevicesVo) {
        cusServicesRepository.updateMessageStatus(curSevicesVo.getId(),curSevicesVo.getMessageStatus());
    }
}
